<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"         
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <h:body>
<ui:composition template="/templates/templateNECS.xhtml">

            <ui:define name="top">
                Carrinhos de Compras
            </ui:define>

            <ui:define name="left">
                <br /><br />  
                <h:form>
                <h:commandLink action="#{administradorManager.criarEncomenda()}" value="Criar novo Carrinho de Encomendas"/>
                </h:form>
                <br /><br />       
                <h:outputLink value="admin_farmacia_index.xhtml">voltar</h:outputLink>                                
            </ui:define>
        

       

           
        <ui:define name="content">
            <h:form>       

                    <h:dataTable
                        var="encomenda"
                        summary="Lista de todas as Encomendas"
                        value="#{administradorManager.encomendas}"
                        rules="all"
                        cellpadding="5">
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Data" />
                            </f:facet>
                            <h:outputText value="#{encomenda.dataEncomenda}" />
                            <!--Falta validar o formato-->
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Fechada" />
                            </f:facet>
                            <h:outputText value="#{encomenda.estadoEncomenda()}" />
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Lista de Produtos" />
                            </f:facet>
                            <h:commandButton style="width:100%" value="produtos" action="#{administradorManager.setEncomendaAtualById(encomenda.id)}" />
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Fechar Encomenda" />
                            </f:facet>
                            <h:commandButton style="width:100%" value="fechar" action="#{administradorManager.fecharEncomenda(encomenda.id)}" />
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Apagar" />
                            </f:facet>
                            <h:commandButton style="width:100%"  value="Apagar" action="add_prod" />
                        </h:column>
                        
                    </h:dataTable>
                </h:form>
        </ui:define>
    </ui:composition>
    </h:body>
</html>